#include <iostream>

using namespace std;

template <typename T>
class SquareMatrixBase
{
protected:
    SquareMatrixBase(std::size_t n, T *pMem)
        :size(n)
         ,pData(pMem)
    {}

    void setDataPtr(T *ptr)
    {
        pData = ptr;
    }

    void invert(std::size_t matrixSize);

private:
    std::size_t size;
    T *pData;
};

template <typename T, std::size_t n>
class SquareMatrix : private SquareMatrixBase<T>
{
public:
    SquareMatrix()
        :SquareMatrixBase<T>(n, data)
    {}

    void insert()
    {
        this->invert(n);
    }
private:
    T data[n * n];
};

